package service

import (
	"context"

	v1 "kratos_kafka_new/api/helloworld/v1"
	"kratos_kafka_new/internal/biz"
)

// GreeterService is a greeter service.
type GreeterService struct {
	v1.UnimplementedGreeterServer

	uc *biz.GreeterUsecase
}

// NewGreeterService new a greeter service.
func NewGreeterService(uc *biz.GreeterUsecase) *GreeterService {
	return &GreeterService{uc: uc}
}

// 在这里往kafka中写入一些数据
func (s *GreeterService) SayHello(ctx context.Context, in *v1.SayHelloReq) (*v1.Empty, error) {
	err := s.uc.CreateGreeter(ctx, in)
	if err != nil {
		return nil, err
	}
	return &v1.Empty{}, nil
}
